package com.ccp.dev.workflow.model;

import com.ccp.dev.core.basic.model.BaseModel;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Objects;

/**
 * ClassDescribe  Identity 流水号Model类
 * @author fanruiqi
 * Date: 2019-08-29
 * Since:1
 * To change this template use File | Settings | File Templates.
 */

@XmlRootElement(name="identity")
@XmlAccessorType(XmlAccessType.NONE)
public class Identity extends BaseModel<Identity> {

    /**
     *生成流水号时，默认其当前值为-1
     */
    public static final Long BEGIN_CURVALUE = -1L ;

    /**
     * 主键
     */
    @XmlAttribute
    protected String id;
    /**
     * 名称
     */
    @XmlAttribute
    protected String identityName;

    /**
     * 别名
     */
    @XmlAttribute
    protected String alias;

    /**
     * 规则
     */
    @XmlAttribute
    protected String rule;

    /**
     * 每天生成
     */
    @XmlAttribute
    protected Short genType=1;

    /**
     * 流水号长度
     */
    @XmlAttribute
    protected Integer noLength;

    /**
     * 初始值
     */
    @XmlAttribute
    protected Integer initValue;

    /**
     * 当前值
     */
    @XmlAttribute
    protected Long curValue;

    /**
     * 当前日期
     */
    protected String curDate="";

    /**
     * 用户填写的CODE
     */
    @XmlAttribute
    protected String userCode;

    /**
     * 步长
     */
    @XmlAttribute
    protected Short step=1;


    protected Long newCurValue=1L;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getIdentityName() {
        return identityName;
    }

    public void setIdentityName(String identityName) {
        this.identityName = identityName;
    }

    public String getAlias() {
        return alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getRule() {
        return rule;
    }

    public void setRule(String rule) {
        this.rule = rule;
    }

    public Short getGenType() {
        return genType;
    }

    public void setGenType(Short genType) {
        this.genType = genType;
    }

    public Integer getNoLength() {
        return noLength;
    }

    public void setNoLength(Integer noLength) {
        this.noLength = noLength;
    }

    public Integer getInitValue() {
        return initValue;
    }

    public void setInitValue(Integer initValue) {
        this.initValue = initValue;
    }

    public Long getCurValue() {
        return curValue;
    }

    public void setCurValue(Long curValue) {
        this.curValue = curValue;
    }

    public String getCurDate() {
        return curDate;
    }

    public void setCurDate(String curDate) {
        this.curDate = curDate;
    }

    public String getUserCode() {
        return userCode;
    }

    public void setUserCode(String userCode) {
        this.userCode = userCode;
    }

    public Short getStep() {
        return step;
    }

    public void setStep(Short step) {
        this.step = step;
    }

    public Long getNewCurValue() {
        return newCurValue;
    }

    public void setNewCurValue(Long newCurValue) {
        this.newCurValue = newCurValue;
    }

    @Override
    public String toString() {
        return "Identity{" +
                "id='" + id + '\'' +
                ", identityName='" + identityName + '\'' +
                ", alias='" + alias + '\'' +
                ", rule='" + rule + '\'' +
                ", genType=" + genType +
                ", noLength=" + noLength +
                ", initValue=" + initValue +
                ", curValue=" + curValue +
                ", curDate='" + curDate + '\'' +
                ", userCode='" + userCode + '\'' +
                ", step=" + step +
                ", newCurValue=" + newCurValue +
                ", createBy='" + createBy + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", updateBy='" + updateBy + '\'' +
                ", tenantId='" + tenantId + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()){
            return false;
        }
        Identity identity = (Identity) o;
        return id.equals(identity.id) &&
                identityName.equals(identity.identityName) &&
                alias.equals(identity.alias) &&
                rule.equals(identity.rule) &&
                genType.equals(identity.genType) &&
                noLength.equals(identity.noLength) &&
                initValue.equals(identity.initValue) &&
                curValue.equals(identity.curValue) &&
                curDate.equals(identity.curDate) &&
                userCode.equals(identity.userCode) &&
                step.equals(identity.step) &&
                newCurValue.equals(identity.newCurValue);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, identityName, alias, rule, genType, noLength, initValue, curValue, curDate, userCode, step, newCurValue);
    }
}